package com.leetcode.LC_MED;

import com.review.test.Solution;

import java.util.ArrayList;
import java.util.TimeZone;

public class LC41 {

    public int firstMissingPositive2(int[] nums) {
        int n = nums.length;
        for (int i = 0; i < n; ++i) {
            while (nums[i] > 0 && nums[i] <= n && nums[nums[i] - 1] != nums[i]) {
                int temp = nums[nums[i] - 1];
                nums[nums[i] - 1] = nums[i];
                nums[i] = temp;
            }
        }
        for (int i = 0; i < n; ++i) {
            if (nums[i] != i + 1) {
                return i + 1;
            }
        }
        return n + 1;
    }

    public static void main(String[] args) {
        LC41 lc41 = new LC41();
        int i = lc41.firstMissingPositive2(new int[]{2,1});
        System.out.println(i);

        System.out.println(TimeZone.getDefault().getID());

        ArrayList<Object> objects = new ArrayList<>();
        System.out.println(objects);
    }
}
